package org.gpp.proj1.communication.processor;

import java.rmi.Remote;
import java.rmi.RemoteException;

import org.gpp.proj1.communication.protocol.Message;

/**
 * Interface for a server connection to a client.
 * Implementations of this interface should *not* be
 * synchronized, since different threads will concurrently
 * access methods like ping and send.
 * @author Gustavo de Farias
 */
public interface RequestProcessorIF extends Remote {
	
	public static final String REQUEST_PROCESSOR = "REQUEST_PROCESSOR";
	
	/**
	 * Invoked by a client to connect to this processor
	 * @param serverId The id the client generated for the server
	 * @param clientPort The client's request processor port
	 * @return The client's generated id
	 * @throws RemoteException
	 */
	public String connect( String serverId, int clientPort ) throws RemoteException;
	
	/**
	 * Disconnect client.
	 */
	public void disconnect( String clientUUID ) throws RemoteException;
	
	/**
	 * Ping client and wait response.
	 */
	public void ping() throws RemoteException;
	
	/**
	 * Send data to this request processor
	 * 
	 * @param The sent message
	 */
	public void receive( Message message ) throws RemoteException;
	
}